package TCP.TCP通信程序练习2;

import java.io.*;
import java.net.Socket;

public class TCP发送数据 {
    public static void main(String[] args) throws IOException {
        /*创建客户端Socket对象*/
        Socket s = new Socket("127.0.0.1", 10000);
        /*数据来自于键盘输入，直到输入的数据是886，发送数据结束*/
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        /*封装输出流对象*/
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
        String line;
        while ((line=br.readLine())!=null){
            if("886".equals(line)){
                break;
            }
            bw.write(line);
            bw.newLine();
            bw.flush();
        }
        /*释放资源*/
        s.close();
    }
}